﻿using System;
using System.Collections.Generic;
using System.Text;
using Watchdog.Bll.Factory;

namespace Watchdog.Bll.Base {

    public partial class TestHistoryBase {

        #region [ Local variables ]
        Facade.TestHistory intdata;
        #endregion

        #region [ Constructor(s) ]
        internal TestHistoryBase () {
            intdata = new Watchdog.Facade.TestHistory ();
        }
        internal TestHistoryBase (Facade.TestHistory testhistory) : base () {
            intdata = testhistory;
        }
        #endregion

        #region [ Field Properties ]
        public int Id {
            get { return intdata.Id; }
        }
        public virtual int Test {
            get { return intdata.Test; }
            set { intdata.Test = value; }
        }
        public virtual int Target {
            get { return intdata.Target; }
            set { intdata.Target = value; }
        }
        public virtual DateTime Started {
            get { return intdata.Started; }
            set { intdata.Started = value; }
        }
        public virtual DateTime Stopped {
            get { return intdata.Stopped; }
            set { intdata.Stopped = value; }
        }
        public virtual int Result {
            get { return intdata.Result; }
            set { intdata.Result = value; }
        }
        public virtual string ResultMessage {
            get { return intdata.ResultMessage; }
            set { intdata.ResultMessage = value; }
        }
        public virtual bool NotifySent {
            get { return intdata.NotifySent; }
            set { intdata.NotifySent = value; }
        }
		#endregion
		
        #region [ Data Methods ]
        public void Update () {
            if (Id == -1)
                TestHistoryFactory.Insert ( this );
            else
                TestHistoryFactory.Update ( this );
        }

        public void Delete () {
            TestHistoryFactory.Delete ( this );
        }
        #endregion

		#region [ Many to many relations native type ]

		#endregion

		#region [ Add & Remove methods for many to many relations native type ]

		#endregion
		
        internal Facade.TestHistory IntData {
            get { return intdata; }
            set { intdata = value; }
        }

        #region [ Equality ]
        public override int GetHashCode () {
            return Id;
        }
        public static bool operator == ( TestHistoryBase lt1, TestHistoryBase lt2 ) {
            if (System.Object.ReferenceEquals ( lt1, lt2 ))
                return true;

            if ((object)lt1 == null || (object)lt2 == null)
                return false;
            return lt1.Equals ( lt2 );
        }
        public static bool operator != ( TestHistoryBase lt1, TestHistoryBase lt2 ) {
            if (lt1 == null || lt2 == null)
                return false;
            return !(lt1 == lt2);
        }

        public override bool Equals ( object obj ) {
            if (!(obj is TestHistoryBase))
                return false;
            return (this.CompareTo ( obj ) == 0);
        }

        private int CompareTo ( object obj ) {
            if (!(obj is TestHistoryBase)) {
                throw new ArgumentException ( "A 'TestHistoryBase' object is required for comparison." );
            }
            return this.Id.CompareTo ( ((TestHistoryBase)obj).Id );
        }
        #endregion

	}
}
